package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-08-21  12:40
 */
class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(this.name + "在吃饭！");
    }
}

class Dog extends Animal {
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name + "在吃狗粮！");
    }
}

class Cat extends Animal {
    public Cat(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name + "在吃猫粮！");
    }
}
public class Test {
    public static void main(String[] args) {
        Animal animal = new Dog("小丁",10);
        Animal animal1 = new Cat("小慧",18);
        animal.eat();
        animal1.eat();
    }
}

